package com.sq.myrule;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: TODO
 * @author: ydy
 * @date: 2022-09-12 10:18
 */

//不能使得Ribbon在主启动类所在的包及其子包中，既不能被主启动类的@SpringBootApplication
//@ComponentScan注解所扫描到
@Configuration
public class MySelfRule {
    @Bean
    public IRule myRule(){
        // 不使用默认的轮询，自定义负载均衡策略为随机
        return new RandomRule();
    }
}
